export function isArray(obj) {
    return obj && obj.constructor === Array
}

export function isObject(obj) {
    return obj && obj.constructor === Object
}

export function isEmpty(v) {
    if (v === null || v === undefined) return true
    return typeof v === 'string' && v.trim() === '';
}

export function downloadFileByBlob(blob, fileName = "file") {
    let blobUrl = window.URL.createObjectURL(blob)
    let link = document.createElement('a')
    link.download = decodeURI(fileName)
    link.style.display = 'none'
    link.href = blobUrl
    // 触发点击
    document.body.appendChild(link)
    link.click()
    // 移除
    document.body.removeChild(link)
}

export function equals(a, b) {
    if (typeof a !== typeof b) {
        return false;
    }
    if (typeof a.equals === 'function') {
        return a.equals(b)
    }
    if (typeof b.equals === 'function') {
        return b.equals(a)
    }
    return JSON.stringify(a) === JSON.stringify(b)
}